<template>
  <div id="app">
      <top_header></top_header>
      <keep-alive>
          <router-view></router-view>
      </keep-alive>
      <scrollToTop></scrollToTop>
      <loading></loading>
      <footer></footer>
  </div>
</template>
<script>
import scrollToTop from "./components/scrollToTop";
import loading from "./components/loading";
import top_header from "./components/top-header";
export default {
    data(){
        return{
            
        }
    },
    created(){
        // 读取token
        var token=localStorage.getItem("token");
        this.$store.commit("update_token",token?token:"");
        // 全局loading显示隐藏
        this.$store.commit("loading",true);
        this.$router.beforeEach((to,from,next)=>{
            this.$store.commit("loading",true);
            this.$store.commit("type_flag",!to.meta.type_flag);
            next();
        })
        this.$router.afterEach(()=>{
            // 切换标题
            document.title=this.$route.name;
            // 刷新
            this.$store.commit("type_flag",!this.$route.meta.type_flag);
            this.$nextTick(()=>{
                this.$store.commit("loading",false);
            })
        })
        this.$router.replace(location.pathname);
    },
    components:{
        scrollToTop,
        loading,
        top_header
    },
    methods:{
        
    }
}
</script>
<style>
    /* footer{
        background: url('./assets/footer.png') center center no-repeat;
        height:400px;
        margin-top:50px
    } */
</style>
